﻿<Window x:Class="XOS_VHD_Tools.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ex="http://schemas.xceed.com/wpf/xaml/toolkit"
        Title="MainWindow" Height="513" Width="708" 
        xmlns:my="clr-namespace:XOS_VHD_Tools"
        xmlns:myfs="clr-namespace:XOS_VHD_Tools.VHD"
        MinHeight="200" MaxHeight="700" Loaded="Window_Loaded">
    <Window.Resources>
        <my:VHDNameConverter x:Key="VHDNameConv" />
        <my:FSEntryToImageSource x:Key="objToIcon" />
        <my:FSDirectoryToRootObj x:Key="rootObj" />
        <my:IsNotStringEmptyConverter x:Key="isNotStringEmpty" />
    </Window.Resources>
    <Grid>
        <ex:BusyIndicator IsBusy="{Binding Path=IsBusy}">
            <DockPanel x:Name="__ctrlHolder" Margin="1.5">
                <Grid  DockPanel.Dock="Top">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <Label Grid.Row="0" Grid.Column="0" Padding="2,0">VHD file:</Label>
                    <Label Grid.Row="0" Grid.Column="1" Content="{Binding Path=VHD, Converter={StaticResource VHDNameConv}}" Padding="4,0"/>
                    <Button Grid.Row="0" Grid.Column="2" Padding="0" Click="OpenVHD">
                        <Image Width="16" Height="16" Margin="0" Source="/XOS_VHD_Tools;component/Images/zoom.png" />
                    </Button>
                </Grid>
                <GroupBox  DockPanel.Dock="Top" Header="VHD manupulations:">
                    Update boot sector
                Format disk
                Install XOS
                </GroupBox>
                <GroupBox Visibility="Collapsed" DockPanel.Dock="Top">
                    <GroupBox.Header>
                        <CheckBox>Update OS (core/JIT/extensions &amp; etc)</CheckBox>
                    </GroupBox.Header>
                </GroupBox>

                <GroupBox DockPanel.Dock="Top" Header="Drive browser (just primary partitions):">
                    <DockPanel>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition MinWidth="4" Width="Auto"/>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <StackPanel Orientation="Horizontal">
                                <Button x:Name="btnCreateFolder" Margin="2"  IsEnabled="False" Click="btnCreateFolder_Click">
                                    <Image Height="16" Width="16" Source="/XOS_VHD_Tools;component/Images/folder_add.png" />
                                </Button>
                                <Button x:Name="btnDeleteItem" Margin="2" IsEnabled="False" Click="btnDeleteItem_Click">
                                    <Image Height="16" Width="16" Source="/XOS_VHD_Tools;component/Images/delete.png"/>
                                </Button>
                            </StackPanel>
                            <TreeView x:Name="_itVHD" ItemsSource="{Binding Path=VHD.Partitions, Converter={StaticResource rootObj}}" Grid.Row="1" SelectedItemChanged="_itVHD_SelectedItemChanged">
                                <TreeView.ItemTemplate>
                                    <HierarchicalDataTemplate DataType="{x:Type myfs:IDirectory}" ItemsSource="{Binding Entries}">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="{Binding Converter={StaticResource objToIcon}}" />
                                            <Label Content="{Binding Name}" Padding="4, 0"/>
                                        </StackPanel>
                                    </HierarchicalDataTemplate>
                                </TreeView.ItemTemplate>
                            </TreeView>

                            <StackPanel Grid.Column="1" Grid.RowSpan="2" VerticalAlignment="Center">
                                <Button x:Name="btnToVHD" Margin="2" IsEnabled="False" Click="btnToVHD_Click">
                                    <Image Height="16" Width="16" Source="/XOS_VHD_Tools;component/Images/arrow_left.png" />
                                </Button>
                                <Button x:Name="btnToHD" Margin="2" IsEnabled="True" Click="btnToHD_Click">
                                    <Image Height="16" Width="16" Source="/XOS_VHD_Tools;component/Images/arrow_right.png" />
                                </Button>
                            </StackPanel>

                            <TreeView x:Name="_itHD" Grid.Column="2" ItemsSource="{Binding Path=AvailableDrives}" Grid.Row="1" SelectedItemChanged="_itHD_SelectedItemChanged">
                                <TreeView.ItemTemplate>
                                    <HierarchicalDataTemplate DataType="{x:Type myfs:IDirectory}" ItemsSource="{Binding Entries}">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="{Binding Converter={StaticResource objToIcon}}" />
                                            <Label Content="{Binding Name}" Padding="4, 0"/>
                                        </StackPanel>
                                    </HierarchicalDataTemplate>
                                </TreeView.ItemTemplate>
                            </TreeView>

                        </Grid>
                    </DockPanel>
                </GroupBox>
            </DockPanel>
        </ex:BusyIndicator>

        <Border Background="#7f000000" Visibility="{Binding ElementName=__nameDlg,Path=Visibility}">
            <ex:ChildWindow x:Name="__nameDlg" WindowStartupLocation="Center"
                        Width="300" BorderThickness="0.4" Caption="Name" 
                        CloseButtonVisibility="Collapsed" 
                        OverlayBrush="#7f000000" >
                <StackPanel Margin="2">
                    <TextBox x:Name="_itemName" PreviewTextInput="_itemName_PreviewTextInput" />
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <Button Width="75" Margin="1" IsDefault="True" IsEnabled="{Binding ElementName=_itemName, Path=Text, Converter={StaticResource isNotStringEmpty}}" Click="Button_Click_1">OK</Button>
                        <Button Width="75" Margin="1" IsCancel="True" Click="Button_Click">Cancel</Button>
                    </StackPanel>
                </StackPanel>
            </ex:ChildWindow>
        </Border>
    </Grid>
</Window>
